<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>标签</title>
    <link rel="stylesheet" href="{% static 'css/static_css.css' %}">
    <script src="{% static 'js/index.js' %}"></script>
</head>
<body>
    {% if age > 18 %}
    	<h1>你已经成年了！</h1>
    {% elif age ==  18 %}
        <h1><a href="{% url 'try' 18%}">你刚好18岁了！</a></h1>
    {% else %}
    	<h1>你还未成年！</h1>
    {% endif %}
    <table>
        <thead style="text-align: left">
            <tr>
                <th>forloop.counter</th>
                <th>forloop.counter0</th>
                <th>姓名</th>
                <th>年龄</th>
            </tr>
        </thead>
        <tbody>
            {% for item in books %}
                <tr>
                    <td style="text-align: center">{{ forloop.counter }}</td>
                    <td style="text-align: center">{{ forloop.counter0 }}</td>
                    <td>{{ item.name }}</td>
                    <td>{{ item.age }}</td>
                </tr>
                {% empty %}
                    <tr>
                        <td colspan="4" style="text-align: center">暂无数据</td>
                    </tr>
            {% endfor %}
            {% for item in null %}
                <tr>
                    <td style="text-align: center">{{ forloop.counter }}</td>
                    <td style="text-align: center">{{ forloop.counter0 }}</td>
                    <td>{{ item.name }}</td>
                    <td>{{ item.age }}</td>
                </tr>
                {% empty %}
                    <tr>
                        <td colspan="4" style="text-align: center">暂无数据</td>
                    </tr>
            {% endfor %}
        </tbody>
    </table>
    <div>
        {% for item in books %}
            {% for key, value in item.items %}
                <p>{{ key }}: {{ value }}</p>
            {% endfor %}
        {% endfor %}
    # 逆序输出(reversed)
        {% for item in books reversed %}
            {% for key, value in item.items %}
                <p>{{ key }}: {{ value }}</p>
            {% endfor %}
        {% endfor %}
    </div>
    <div>
        {{ books.0.name }}
        {% with name=books.0.name %}
            {{ name }}
        {% endwith %}
        {{ books.2.name| upper }} <!-- "|"为管道符，后面添加过滤器（函数）--><br>
        {{ books.2.name| lower }}<br>
        {{ books.2.name| cut:" " }}<br> <!-- 删除指定的字符 -->
        {{ books.2.name| cut:"d" }}<br>
        {{ datetime_now| date:"Y-m-d H:i:s" }}<br> <!-- 格式化日期 -->
        {{ text| default:"默认值" }}<br> <!-- 如果为False，则输出默认值, 否则输出原值 -->
        {{ text1| default_if_none:"默认值" }}<br> <!-- 输出默认值 -->
        {{ books.2.name| length }}<br> <!-- 输出字符串长度 -->
        {{ books.2.name| slice:"2:5" }}<br> <!-- 输出字符串和数组切片 -->
        {{ books.2.name| truncatechars:5 }}<br> <!-- 输出指定字符串的长度，其他用省略号表示 -->
        {{ books.2.name| add:" 我是追加的文字" }}<br> <!-- 输出字符串追加 -->
        {{ books.2.name| join:"-" }}<br> <!-- 输出字符串连接 -->
        {{ books.2.name| random }}<br> <!-- 输出随机字符或数字(可以用在数组) -->
        {{ books| random }}<br>
        {{ books.2.name| first }}<br> <!-- 输出第一个字符 -->
        {{ books.2.name| last }}<br> <!-- 输出最后一个字符 -->
        {{ books.2.age| floatformat }}<br> <!-- 默认为一个小数，可指定位数 -->
        {{ books.2.age| floatformat:2 }}<br>
        {{ books.2.age| add:12}}<br><!-- 输出数字加1 -->
    </div>

    <div>
        {% autoescape off %} <!-- 自动转义 -->
            {{ html_content }}
        {% endautoescape %}
        {% autoescape on %} <!-- 自动转义 -->
            {{ html_content }}
        {% endautoescape %}
        {{ biaoqian }}
    </div>
</body>
</html>